<template>
  <div class="Breadcrumb">
    <el-breadcrumb separator="/" class="biaoqian">
      <el-breadcrumb-item :to="{ path: '/teacherInterface' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>教材查看</el-breadcrumb-item>
    </el-breadcrumb>
    <el-divider></el-divider>
  </div>
  <div class="showUnTicketInfo">
    <div class="box">
      <el-form :model="queryForm" size="middle" :inline="true" style="padding-left: 20px;  ">
        <el-form-item label="课程名称">
          <el-input placeholder="请输入课程名称" v-model="queryForm.course" clearable style="width: 240px;" />
        </el-form-item>
        <el-form-item label="标准书号">
          <el-input placeholder="请输入标准书号" v-model="queryForm.isbn" clearable style="width: 240px" />
        </el-form-item>
        <el-form-item label="教材名称">
          <el-input placeholder="请输入教材名称" v-model="queryForm.textbook" clearable style="width: 240px" />
        </el-form-item>
        <el-form-item label="出版社">
          <el-input placeholder="请输入出版社" v-model="queryForm.publisher" clearable style="width: 240px" />
        </el-form-item>
        <el-form-item>
          <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
              <el-button @click="handleSearch" type="primary" :icon="Search" size="mini">搜索</el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button @click="handleReset" :icon="Refresh" size="mini">重置</el-button>
            </el-col>
          </el-row>
        </el-form-item>
      </el-form>

    </div>
    <div class="box-content">
      <el-table :data="dataList" height="450" style="width: 100%">
        <el-table-column label="课程名称" prop="courseName" align="center" />
        <el-table-column label="标准书号" prop="isbn" align="center" />
        <el-table-column label="教材名称" prop="name" align="center" />
        <el-table-column label="出版社" prop="publisher" align="center" />
        <el-table-column label="编者" prop="author" align="center" />
        <el-table-column label="估价" prop="price" align="center" />
        <el-table-column label="出版时间" prop="publishDate" align="center" />
        <el-table-column label="班级" prop="className" align="center" />
      </el-table>
      <div class="pagination">
        <el-pagination layout="prev, pager, next" :total=pageTotal :page-size="pageSize"
          v-model:current-page="curPage" />
      </div>
    </div>
  </div>

</template>

<script>
import api from '@/api/api';
import { Delete, Edit, Search, Share, Upload, Refresh, Plus } from '@element-plus/icons-vue'

export default {
  mounted() {
    this.getData()
  },
  data() {
    return {
      dataList: [],
      curPage: 1,
      pageSize: 5,
      pageTotal: 0,
      queryForm: {
        course: '',
        isbn: '',
        textbook: '',
        publisher: ''
      }
    }
  },
  methods: {
    getData() {
      api.textbook.page(this.curPage, this.pageSize, this.queryForm.course, 
      this.queryForm.isbn, this.queryForm.textbook, this.queryForm.publisher)
        .then((res) => {
          this.dataList = res.data.data.records
          this.pageTotal = res.data.data.total
        })
        .catch((err) => {
          console.log(err)
        })
    },
    handleSearch() {
      this.getData()
    },
    handleReset() {
      this.queryForm.course = ''
      this.queryForm.isbn = ''
      this.queryForm.textbook = ''
      this.queryForm.publisher = ''
      this.getData()
    }
  },
  watch: {
    curPage(newValue, oldValue) {
      this.getData()
    }
  },
  computed: {
    Search() {
      return Search
    },
    Refresh() {
      return Refresh
    },
    Plus() {
      return Plus
    },
    Edit() {
      return Edit
    },
    Delete() {
      return Delete
    }
  }
}
</script>